<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2023/4/13
 * Time: 9:43
 */

namespace app\index\model;


use think\Model;
class CrmMedia extends Model
{
    public function mediaNext(){
        return $this->hasMany('CrmMediaNext','media_id','id')->field('id,media_id,type');
    }

    public function getIsLimitTextAttr($value,$data)
    {
        $status = [0=>'否',1=>'是'];
        return $status[$data['is_limit']];
    }

    public function mediaList($input,$type=false){
        $input['type']=$type;
        $media = $this->where(function ($query) use ($input){
            if(isset($input['media_id'])){
                $query->where('id','in',$input['media_id']);
            }
            if($input['type']){
                $query->where('is_hide',1);
            }
        })->with('mediaNext')->field('id,media,price,jiesuan_price,ticheng_rate,youxiao_status,price_jiesuan')->select();

        return ['list'=>$media];
    }



}